<?php
namespace com\mvc\core;
class Cookies{
	private $cookies;
	private $val_cookie;
	
	public function __construct(&$cookies){
		$this->cookies = $cookies;
	}
	
	public function getCookies(){
		return $this->cookies;
	}
	
	public getCookie($key){
		if (isset($this->cookies) && is_array($this->cookies)){
			return $this->cookies[$key];
		}else{
			return null;
		}
	}
	
	public function addCookieValue($key,$value){
		if (!isset($this->val_cookie)){
			$this->val_cookie = array();
		}
		$this->val_cookie[$key] = $value;
	}
	
	public setCookie($values){
		if (!isset($values['value'])){
			setcookie($values['name']));
		}else if (!isset($values['expire'])){
			setcookie($values['name'],$values['value']);
		}else if (!isset($values['path'])){
			setcookie($values['name'],$values['value'],$values['expire']);
		}else if (!isset($values['domain'])){
			setcookie($values['name'],$values['value'],$values['expire'],$values['path']);
		}else if (!isset($values['secure'])){
			setcookie($values['name'],$values['value'],$values['expire'],$values['path'],$values['domain']);
		}else if (!isset($values['httponly'])){
			setcookie($values['name'],$values['value'],$values['expire'],$values['path'],$values['domain'],$values['secure']);
		}else{
			setcookie($values['name'],$values['value'],$values['expire'],$values['path'],$values['domain'],$values['secure'],$values['httponly']);
		}
		
	}
	
	public function removeCookies(){
		unset($this->cookies);
		unset($this->val_cookie);
	}
	
	public function removeCookies($key){
		unset($this->cookies[$key]);
	}
	
	public resetBuilderCookie(){
		unset($this->val_cookie);
	}
}
?>